/*
 * AIPart.h
 *
 *  Created on: Sep 1, 2017
 *      Author: gaoyi
 */

#pragma once

#include "Character/Creature.h"
#include "Character/Part.h"
#include "Character/newAI/AIData/AIData.h"

#include "Common/DeclareProperty.h"

enum AIPartTimer
{
	AI_STATE_TIMER = 0, //AI ״̬��ʱ��
	AI_STATE_TIMER_INTERNAL = 500, //AI ״̬��ʱ�� ���ʱ��
	AI_RESTART_TIMER = 1, //AI ������ʱ��
};

class AIPart : public Part
{
public:
	AIPart();
	virtual ~AIPart();
	bool Init(Creature *pMaster, uint32_t partType, CharacterDBInfo* pCharacterDB = nullptr);
	bool UnInit();
	void OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen);
	bool OnMsgHandle(uint32_t cmd, const char* data, uint32_t len);
	void OnTimer(uint32_t nTimerId);
public:
    // AI״̬������
    int HeartBeat_AIStatus();

    // AI��������
    int HeartBeat_AIWarning();

    // ����һ��޵���������
    int HeartBeat_GetFirstHate();
public:
    //����AI������
    int HeartBeat_RestartAI();

    //�����ƶ�������
    int HeartBeat_RestartMove();

    //������ת������
    int HeartBeat_RestartRotate();
public:
    /**
    *@brief  ����AI
    *@return void
    */
    void StartAI();
    /**
    *@brief  ֹͣAI(�˷�����Ҫ��StartAI���� ���
    *@return void
    */
    void StopAI();
    /**
    *@brief  ֹͣAI(�����ֹͣAI�ڼ䣬�����ֹͣAI���������ʱ�䴦��)
    *@param  [in] uTime ֹͣʱ��(ms)
    *@return void
    */
    void StopAI(int uTime);
public:
    void OpenStateTimer();									//����״̬��ʱ��
    void CloseStateTimer();									//�ر�״̬��ʱ��
    void OpenReStartAITimer();								//����������ʱ��
    void CloseReStartAITimer();								//�ر�������ʱ��
public:
	DECLARE_PROPERTY_OBJECT_PTR(AIData, AiData);			//AI����
	DECLARE_PROPERTY_INT32(AIState);							//AI����״̬
	DECLARE_PROPERTY_BOOL(StateTimer);						//״̬ ��ʱ������
	DECLARE_PROPERTY_BOOL(ReStartAITimer);					//������ʱ��
	DECLARE_PROPERTY_UINT64(AIStopCurTime);					//��ͣAIʱ��
	DECLARE_PROPERTY_UINT64(AIStopTime);					//��ͣAIʱ�䳤��
};

